#include <rtthread.h>
#include "base.h" 
#include "rtconfig.h"
#include "rtdef.h"

static struct rt_mutex log_mutex;

void task_entry(void *parameter)
{
    while (1)
    {
        rt_mutex_take(&log_mutex, RT_WAITING_FOREVER);

        rt_kprintf("%s is running\n", rt_thread_self()->name);
        rt_mutex_release(&log_mutex);
    }
}

int main(void)
{
    hardware_init();

    // 初始化互斥锁
    rt_mutex_init(&log_mutex, "log", RT_IPC_FLAG_FIFO);

    // 创建多个任务
    rt_thread_startup(rt_thread_create("t1", task_entry, RT_NULL, 1024, 10, 10));
    rt_thread_startup(rt_thread_create("t2", task_entry, RT_NULL, 1024, 10, 10));

    return 0;
}